FROM debian:bullseye

#COPY ./sources.list.bullseye /etc/apt/sources.list

RUN apt-get update
RUN apt-get -y --quiet --force-yes upgrade curl iproute2 bash
RUN apt-get install -y --no-install-recommends ca-certificates gcc g++ make cmake build-essential git
RUN apt-get install -y libopus-dev libiptc-dev libavfilter-dev libncurses5-dev libncursesw5-dev rsyslog
RUN apt-get install -y  libevent-dev libpcap-dev libxmlrpc-core-c3-dev markdown ffmpeg\
  libjson-glib-dev default-libmysqlclient-dev libhiredis-dev libssl-dev pandoc\
  libcurl4-openssl-dev libavcodec-extra gperf libspandsp-dev libwebsockets-dev\
  # && echo "140.82.116.4 github.com" >> /etc/hosts \
  && cd /usr/local/src \
  && git clone https://github.com/BelledonneCommunications/bcg729.git \
  && cd bcg729 \
  && sed -i "s/VERSION 3.22/VERSION 3.18/" CMakeLists.txt \
  && cmake . -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_PREFIX_PATH=/usr \
  && make &&make install \
  && cd .. \
  && git clone https://github.com/sipwise/rtpengine.git -b mr11.5.1.34 \
  && cd rtpengine/daemon \
  && make && make install \
  && cd ../recording-daemon \
  && make && make install \
  && cp /usr/local/src/rtpengine/daemon/rtpengine /usr/local/bin/rtpengine \
  && cp /usr/local/src/rtpengine/recording-daemon/rtpengine-recording /usr/local/bin/rtpengine-recording \
  && rm -Rf /usr/local/src/rtpengine \
  && apt-get purge -y --quiet --force-yes --auto-remove \
  ca-certificates gcc g++ make cmake build-essential git markdown \
  && rm -rf /var/lib/apt/* \
  && rm -rf /var/lib/dpkg/* \
  && rm -rf /var/lib/cache/* \
  && rm -Rf /var/log/* \
  && rm -Rf /usr/local/src/* \
  && rm -Rf /var/lib/apt/lists/*

VOLUME ["/tmp"]
ENV SHELL=/bin/bash
# rtpengine-recording运行前需要预先创建，否则会报错，可以在配置文件中修改
RUN mkdir -p /dev/shm/rtpengine

COPY ./entrypoint.sh /entrypoint.sh
COPY ./rtpengine.conf.orig /etc/rtpengine/
COPY ./rtpengine-recording.conf.orig /etc/rtpengine/

RUN chmod +x ./entrypoint.sh
